# -*- cording: UTF-8 -*-

from OPAP.bem import *
from pylab import *

if __name__ == "__main__":
    
    """
    An example of OPAP.BEM module. 
    """
    
    # Frequency for calculation
    freqs=arange(100, 150, 5)
    # Source Sound Position.
    srcPos=array([[-5,1]])
    # Recording Position
    recPos=array([[-1,1], [3,1]])
    
    # line positon 
    lines=[line(0,0,0,1,0),line(0,1,1,1,0),line(1,1,1,0,0),line(1,0,0,0,0)]
        
    # Main Calculation
    bem = BEM(srcPos, recPos, lines, freqs)
    bem.calc()
    
    print bem.result

    hold(True)
    plot(freqs, bem.result[:,0], "r", label="recPos"+str(recPos[0]), linewidth=1)
    plot(freqs, bem.result[:,1], "g", label="recPos"+str(recPos[1]), linewidth=1)
    xlim([freqs[0], freqs[-1]])
    legend()
    grid(True)
    show()